package LeetCode.month02.day43;
import java.util.ArrayList;
import java.util.List;

public class No228 {
    public List<String> summaryRanges(int[] nums) {
        int n = nums.length;
        List<String> list = new ArrayList<>();
        int index = 0;
        while(index<n){
            int left = index;
            index++;
            while(index<n&&nums[index]-nums[index-1]==1){
                index++;
            }
            if(left==index-1) {
                list.add(nums[left]+"");
            }
            else{
                list.add(nums[left]+"->"+(nums[index-1]));
            }
        }
        return list;
    }
}
